package com.org.zp.ctrl.more;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.org.base.ctrl.ActivityTaskManager;
import com.org.base.ctrl.BaseActivity;
import com.org.base.util.Update;
import com.org.zp.R;
import com.org.zp.app.RecApp;

public class MoreActivity extends BaseActivity implements OnClickListener {
	/** Called when the activity is first created. */

	private RelativeLayout more_update;
	private RelativeLayout more_aboutus;
	private RelativeLayout more_modifypsw;
	private RelativeLayout more_contactus;

	private RecApp app;
	
	private TextView title;
	private Button back_btn;
	private Button enable_btn;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.more);

		app = (RecApp) getApplication();

		if (!(ActivityTaskManager.getInstance()
				.containsName("MoreActivity"))) {
			ActivityTaskManager.getInstance().putActivity(
					"MoreActivity", this);
		}

		back_btn = (Button) findViewById(R.id.back);
		enable_btn = (Button) findViewById(R.id.top_right_button);
		enable_btn.setVisibility(View.INVISIBLE);
		back_btn.setText("  返回");
		back_btn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				ActivityTaskManager.getInstance().removeActivity("MoreActivity");
			}
		});
		title = (TextView) findViewById(R.id.headTitle);
		title.setText("更多");
		
		more_update = (RelativeLayout) findViewById(R.id.more_update);
		more_update.setOnClickListener(this);

		more_aboutus = (RelativeLayout) findViewById(R.id.more_aboutus);
		more_aboutus.setOnClickListener(this);

		more_modifypsw = (RelativeLayout) findViewById(R.id.more_modifypsw);
		more_modifypsw.setOnClickListener(this);
		if("".equals(app.user.getuID())){
			more_modifypsw.setVisibility(View.GONE);
		}

		more_contactus = (RelativeLayout) findViewById(R.id.more_contactus);
		more_contactus.setOnClickListener(this);


	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			ActivityTaskManager.getInstance().removeActivity("MoreActivity");
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (v == more_update) {

			Update up = new Update(MoreActivity.this, app, true);
			up.checkUpdate();

		} else if (v == more_aboutus) {

		} else if (v == more_modifypsw) {

		} else if (v == more_contactus) {


		}
	}


}